package top.hkyzf.study.leetcode.string;

import org.junit.Test;

import java.util.Arrays;

/**
 * @author 朱峰
 * @date 2022-1-22 15:35
 */
public class 反转字符串_344 {
    public void reverseString(char[] s) {
        int left = 0;
        int right = s.length - 1;
        char temp;
        while (left < right) {
            temp = s[left];
            s[left] = s[right];
            s[right] = temp;
            left++;
            right--;
        }
    }

    @Test
    public void testReverseString () {
        char[] s = {'H', 'a' ,'n' ,'n', 'a', 'h'};
        reverseString(s);
        System.out.println(Arrays.toString(s));
    }
}
